package com.restaurant.application.minifacade.data;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import java.lang.String;
import java.util.List;

public class TypeBO implements PickableBean {
    
    public static final String FN_TYPEID = "typeId";
    public static final String FN_TYPENAME = "typeName";
    
    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_TYPEID,
             FN_TYPENAME);
    
    private String typeId;
    private String typeName;
    
    public TypeBO(String typeId, String typeName) {
        setTypeId(typeId);
        setTypeName(typeName);
    }
    
    public TypeBO() {
    }
    
    public TypeBO duplicate() {
        TypeBO result = new TypeBO();
        result.typeId = this.typeId;
        result.typeName = this.typeName;
        return result;
    }
    
    @Override
    public String toString() {
        return Convert.toJson(this);
    }
    
    public String getTypeId() {
        return typeId;
    }
    
    public void  setTypeId(String value) {
        this.typeId = value;
    }
    
    public TypeBO withTypeId(String value) {
        setTypeId(value);
        return this;
    }
    
    public TypeBO withTypeId(String value, String defaultValue) {
        setTypeId(value == null ? defaultValue : value);
        return this;
    }
    
    public String getTypeName() {
        return typeName;
    }
    
    public void  setTypeName(String value) {
        this.typeName = value;
    }
    
    public TypeBO withTypeName(String value) {
        setTypeName(value);
        return this;
    }
    
    public TypeBO withTypeName(String value, String defaultValue) {
        setTypeName(value == null ? defaultValue : value);
        return this;
    }
    
    public Object getValueOf(String name) {
        switch(name) {
        case "typeId": return getTypeId();
        case "typeName": return getTypeName();
        }
        return null;
    }
    
    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }
    
    @Override
    public int hashCode() {
        return signature().hashCode();
    }
    
    @Override
    public boolean equals(Object o) {
        if(!(o instanceof TypeBO)) return false;
        return signature().equals(((TypeBO)o).signature());
    }
    
    public String signature() {
        throw new RuntimeException("Bean TypeBO has no signature defined, no hash code or equals possible.");
    }
}
